package com.java.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.java.po.Message;
import com.java.po.MessageMap;
import com.java.service.MessageService;
import com.java.service.impl.MessageServiceImpl;
import com.java.tool.AjaxJson;

/**
 * Title:MessageController.java
 * Description:
 * @author:sprogrammer
 * @time:2018年2月23日下午8:49:26
 */
@Controller
@CrossOrigin()
@RequestMapping(method=RequestMethod.POST)
public class MessageController {
	private AjaxJson ajaxJson;
	@Autowired
	private MessageService messageService;
	
	public MessageController(){
		ajaxJson = new AjaxJson();
		//service = new MessageServiceImpl();
	}
	
	@RequestMapping(value="/insertMessage")
	public @ResponseBody AjaxJson insertMessage(@RequestBody Message message) throws Exception{
		ajaxJson=messageService.insertMessage(message);
		return ajaxJson;
	}
	@RequestMapping(value="/updateMessage")
	public @ResponseBody AjaxJson updateMessage(@RequestBody Message message) throws Exception{
		ajaxJson=messageService.updateMessageByMessageid(message);
		return ajaxJson;
	}
	@RequestMapping(value="/deleteMessage")
	public @ResponseBody AjaxJson deleteMessage(@RequestBody Message message) throws Exception{
		ajaxJson=messageService.deleteMessage(message);
		return ajaxJson;
	}
	@RequestMapping(value="/findAllMessage")
	public @ResponseBody AjaxJson findAllMessage(@RequestBody MessageMap messageMap) throws Exception{
		ajaxJson=messageService.findAllMessage(messageMap);
		return ajaxJson;
	}
	@RequestMapping(value="/findMessageByid")
	public @ResponseBody AjaxJson findMessageByid(@RequestBody Message message) throws Exception{
		ajaxJson=messageService.findMessageByid(message);
		return ajaxJson;
	}
}
